package com.chenl.provider.DEMOS.Mysql.Mybatis.自动装配;

import cn.hutool.core.util.RandomUtil;
import com.chenl.provider.DTO.entity.MyStudent;
import com.chenl.provider.service.StudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("mybatis")
public class MybatisCon {
    @Autowired
    StudentServiceImpl studentService;

    @GetMapping(value = "/test")
    public void test2()  {
        List<MyStudent> list=new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            MyStudent myStudent=new MyStudent();
            myStudent.setId(RandomUtil.randomLong());
            myStudent.setPhone(String.valueOf(RandomUtil.randomLong()));
            myStudent.setStuName("张三");
            myStudent.setStuAge(String.valueOf(RandomUtil.randomLong()));
            list.add(myStudent);
        }

        long l = System.currentTimeMillis();
        studentService.saveBatch(list);
        long l2 = System.currentTimeMillis();
        System.out.println(l2-l);
    }
}
